package com.oj.system.utils;

import org.springframework.security.crypto.bcrypt.BCrypt;
import org.springframework.security.crypto.bcrypt.BCryptPasswordEncoder;

/**
 * ClassName: BCryptUtils
 * Package: com.oj.system.utils
 * Description:
 *
 * @Author 宋斌
 * @Create 2025/4/9 22:35
 * @Version 1.0
 */
public class BCryptUtils {
    public static String encryptPassword(String password) {
        BCryptPasswordEncoder encoder = new BCryptPasswordEncoder();
        return encoder.encode(password);
    }

    public static boolean matchesPassword(String rawPassword, String encodedPassword) {
        BCryptPasswordEncoder encoder = new BCryptPasswordEncoder();
        return encoder.matches(rawPassword, encodedPassword);
    }

    public static void main(String[] args) {
        String s = BCryptUtils.encryptPassword("123456");
        System.out.println(s);
    }
}
